#ifndef MATRIX_H
#define MATRIX_H

#include <qimage.h>
#pragma once
#pragma pack(1)
struct BM
{
    unsigned short bftype;
    unsigned int bfsize;
    unsigned short bfreserved1;
    unsigned short bfreserved2;
    unsigned int bfoffbits;
};

struct BI
{
    unsigned long bisize;
    long biwidth;
    long bihight;
    unsigned short biplanes;
    unsigned short bibitcount;
    unsigned long bicompression;
    unsigned long bisizeimage;
    long bixpelspermeter;
    long biypelspermeter;
    unsigned long biclrused;
    unsigned long biclrimportant;
};

class Matrix
{

public:
    int height;
    int width;
    unsigned char* data;
    BM bm;
    BI bi;
    double **da;
public:
    Matrix(int h, int w);
    Matrix();
    ~Matrix();
    void Readimage(QString  filename);
    void Writeimage(QString filename);
    void light(double t);
    void Flip(int t);
    void doubletosingle();
    void grey();
    void mosaic(int x1, int y1, int x2, int y2, int len);
    void Resize(int h, int w);
    void Cut(int x1, int y1, int x2, int y2);
    void duibidu(double t);
    void Rotate(int code);
    void gaosilvboqi(int ksize =3,double strength=0.8);
    void tidu();
    void baohedu(double percent);//percent的范围是-1到1

    void gamma(double t = 2.2);//对图片做gamma矫正gamma值一般取2.2,调整图片的亮度
    void nonmaxsupersion();//非极大值抑制
    void doublefazhi(double lownumber, double heightnumber);//双阀值检测和边缘连通

    void bianyuantiqu(double t=1,double lownumber=1, double heightnumber=0,int ksize=3, double strength=0.8);//基于canny算子的图像锐化

    void ruihua(double t=1,double lownumber = 1, double heightnumber = 0, int ksize = 3, double strength = 0.8);//增强图像边缘

    void junzhilvboqi(int ksize);
    void zhongzhilvboqi(int ksize);
    void copy(const Matrix &m);
};
#endif // MATRIX_H
